package zachary.hackerson.ds;

/**
 * depth first search
 */
public class Search {
	private boolean[] marked;
	private int count;
	
	public Search(Graph G, int s) {
		marked = new boolean[G.V()];
		dfs(G, s);
	}
	private void dfs(Graph G, int v) {
		marked[v] = true;
		count++;
		for(int w: G.adj(v)) 
			if(!marked[w]) dfs(G, w);
	}
	public boolean marked(int v) {
		return marked[v];
	}
	public int count() {
		return count;
	}
}
